package usf.vend.a.bull;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Point;
import android.location.Location;
import android.widget.Toast;
import android.content.Context;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;

public class LocationOverlay extends Overlay {
	
	private GeoPoint p;
	private Activity act;
	private Context c;
	private boolean to = true;
	
	public LocationOverlay(Activity act){
		this.act = act;
	}
	
	public synchronized void setPoint(GeoPoint point, Context context){
		to = true;
		this.p = point;
		this.c = context;	
	}
	
	public synchronized GeoPoint getPoint(){
		return p;
	}
	
	public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when){
		super.draw(canvas, mapView, shadow);
		Point screenPts = new Point();
		synchronized(this)
		{
			mapView.getProjection().toPixels(p,  screenPts);
		}
		Bitmap bpm = BitmapFactory.decodeResource(act.getResources(), R.drawable.green_arrow);
		canvas.drawBitmap(bpm, screenPts.x - (bpm.getWidth()/2), screenPts.y - bpm.getHeight(), null);
		
		if(to){
                //Toast.makeText(c, 
                   // p.getLatitudeE6() / 1E6 + "," + 
                   // p.getLongitudeE6() /1E6 , 
                   // Toast.LENGTH_SHORT).show();
               // to = false;
		}
		
		return true;
	}

}
